import os from "node:os";

export function getLocalIP() {
    const interfaces = os.networkInterfaces();
    for (const name of Object.keys(interfaces)) {
        for (const net of interfaces[name]) {
            if (net.family === 'IPv4' && !net.internal && !net.address.startsWith('127.')) {
                return net.address;
            }
        }
    }
    return 'localhost';
}
